<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let worker1 = new Worker('worker1.js');
        console.time('时间');
        let num1 = 0;

        worker1.postMessage(num1);
        let worker1Res = 0
        worker1.onmessage = function(e) {
            worker1Res = e.data;
            let numRes = num + worker1Res;
            console.log(num, worker1Res, 'jieg')
        
            console.log(numRes);
            this.terminate()
        }
        let num = 0;
        for (let i = 0; i < 499999999; i++) {
            num = i;
        }
        
        console.timeEnd('时间');
    </script>
</body>
</html>